<?php

function getCommands()
{
//TODO: this function must loop thru the 
//folders and place the stuff in the array.

	$rootUrl = "http://www.glidecast.com/chirplace1.0.0.0.com/modules/";
	$arrCommands = array();

	$basedir = "/home/glidecas/public_html/chirplace1.0.0.0.com/scodes";
	$handler = opendir($basedir);

	while ($file = readdir($handler))
	{
		if ($file != '.' && $file != '..')
		{
			include($basedir."/".$file);
			$scodeitem = array();
			array_push($scodeitem, $scodecode);
			array_push($scodeitem, $scodename);
			array_push($scodeitem, $scodedesc);
			array_push($scodeitem, $scodeparam);
			array_push($scodeitem, $scodeexample);
			array_push($scodeitem, $scodeauthor);
			array_push($scodeitem, $scodeauthorurl);
			array_push($scodeitem, $scodemoduleurl);
			array_push($scodeitem, $scoderetval);
			array_push($arrCommands, $scodeitem);
		}
	}
	closedir($handler);

	return $arrCommands;
}

function getUserCommands($userid, $bGetPending)
{
	$arrCommands = array();

	$basedir = "/home/glidecas/public_html/chirplace1.0.0.0.com/usr/".$userid."/scodes";
	$handler = opendir($basedir);

	while ($file = readdir($handler))
	{
		if ($file != '.' && $file != '..')
		{
			$ext = substr($file, -3);

			if ($bGetPending)//why is this code so ugly?
			{
				if ($ext == "pnd")
				{
					include($basedir."/".$file);
					$scodeitem = array();
					array_push($scodeitem, $scodecode);
					array_push($scodeitem, $scodename);
					array_push($scodeitem, $scodedesc);
					array_push($scodeitem, $scodeparam);
					array_push($scodeitem, $scodeexample);
					array_push($scodeitem, $scodeauthor);
					array_push($scodeitem, $scodeauthorurl);
					array_push($scodeitem, $scodemoduleurl);
					array_push($scodeitem, $scoderetval);
					array_push($arrCommands, $scodeitem);
				}

			}
			else
			{
				if ($ext == "php")
				{
					include($basedir."/".$file);
					$scodeitem = array();
					array_push($scodeitem, $scodecode);
					array_push($scodeitem, $scodename);
					array_push($scodeitem, $scodedesc);
					array_push($scodeitem, $scodeparam);
					array_push($scodeitem, $scodeexample);
					array_push($scodeitem, $scodeauthor);
					array_push($scodeitem, $scodeauthorurl);
					array_push($scodeitem, $scodemoduleurl);
					array_push($scodeitem, $scoderetval);
					array_push($arrCommands, $scodeitem);
				}
			}
		}
	}

	closedir($handler);

	return $arrCommands;

}

?>